<template>
	<view>
		
	<form @submit="formSubmit" @reset="formReset">
		<view class="content">
			<label class="lable">原铁水碳含量</label>
			<text class="v_input">{{dlplssbz.cBz}}</text>
		</view>
		
		<view class="content">
			<label class="lable">原铁水硅含量</label>
			<text class="v_input">{{dlplssbz.siBz}}</text>
		</view>
		<!-- 
		<view class="content">
			<label class="lable">增碳剂碳吸收率</label>
			<text class="v_input">{{dlplssbz.cXsl}}</text>
		</view>
		
		<view class="content">
			<label class="lable">增碳剂有效成分含量</label>
			<text class="v_input">{{dlplssbz.cYxcfhl}}</text>
		</view>
		<view class="content">
			<label class="lable">硅铁吸收率</label>
			<text class="v_input">{{dlplssbz.siXsl}}</text>
		</view>
		
		<view class="content">
			<label class="lable">硅铁有效成分含量</label>
			<text  class="v_input">{{dlplssbz.siYxcfhl}}</text>
		</view>
		<view class="content">
			<label class="lable">废钢碳含量</label>
			<text  class="v_input">{{dlplssbz.fgChl}}</text>
		</view>
		
		<view class="content">
			<label class="lable">废钢硅含量</label>
			<text  class="v_input">{{dlplssbz.fgSihl}}</text>
		</view>
		<view class="content">
			<label class="lable">生铁碳含量</label>
			<text  class="v_input">{{dlplssbz.stChl}}</text>
		</view>
		
		<view class="content">
			<label class="lable">生铁硅含量</label>
			<text class="v_input">{{dlplssbz.stSihl}}</text>
		</view>
		<view class="content">
			<label class="lable">回炉料碳含量</label>
			<text class="v_input">{{dlplssbz.hllChl}}</text>
		</view>
		
		<view class="content">
			<label class="lable">回炉料硅含量</label>
			<text  class="v_input">{{dlplssbz.hllSihl}}</text>
		</view>
		
		 -->
		
		
		
		
		<view class="content">
			<label class="lable">配料总重(kg):</label>
			<input type="number" name="plzz"  class="v_input"  placeholder="请输入" />
		</view>
		
		<view class="content">
			<label class="lable">废钢总重(kg):</label>
			<input type="number" name="fgzz"  class="v_input"  placeholder="请输入" />
		</view>
		
		<view class="content">
			<label class="lable">生铁总重(kg):</label>
			<input type="number" name="stzz"  class="v_input"  placeholder="请输入"/>
		</view>
		
		<view class="break-space"></view>
		<view class="content">
			<label class="lable">增碳剂理论加入量(kg):</label>
			<label class="result" :style="{ color: textColor }">{{ztjjrl}}</label>
		</view>
		<view class="content">
			<label class="lable">硅铁粒理论加入量(kg):</label>
			<label class="result" :style="{ color: textColor }">{{gtljrl}}</label>
		</view>
		<button form-type="submit" class="btn">计算</button>
	</form>
		
	</view>
</template>

<script>
	import configService from '@/common/config.service.js';
	const apiUrl = configService.apiUrl;
	export default {
		data() {
			return {
				dlplssbz : null,
				ztjjrl : 0,
				gtljrl : 0,
				textColor:'black'
			}
		},
		onShow:function(e){
			this.$verify.verify();
		},
		onLoad() {
			this.getPlssBz();
		},
		methods: {
			getPlssBz(){
				uni.request({
					url:apiUrl+'/dlplss/list',
					header:{
						'content-type':'application/json'
					},
					method:'POST',
					data:{
						deptId:uni.getStorageSync("deptId"),
						type: 3
					},
					success: (res) => {
						if(res.statusCode === 200  &&  res.data.data.length > 0 )
						{
							this.dlplssbz = res.data.data[0];
						}else{
							uni.showModal({
							    title: '提示',  //提示标题
							    content: '请维护电炉配料速算标准！',  //提示内容
							    showCancel: true, //是否显示取消按钮
							    success: function (res) {
							        if (res.confirm) {  //confirm为ture，代表用户点击确定
							            console.log('点击了确定按钮');
							        } else if (res.cancel) {  //cancel为ture，代表用户点击取消
							            console.log('点击了取消按钮');
							        }
							    }
							})
						}
					}
				})
			},
			formSubmit(e) {
				var _this = this;
				if(_this.dlplssbz == null){
					uni.showToast({
						title: "请维护电炉配料速算标准！",
						icon:'error',
						duration:1000
					});
					return ;
				}
				let formData = e.detail.value;
				// 标准碳含量
				let bzchl = formData.plzz*this.dlplssbz.cBz;
				// 现有碳含量
				let xythl = formData.fgzz*this.dlplssbz.fgChl+formData.stzz*this.dlplssbz.stChl+(formData.plzz-formData.fgzz-formData.stzz)*this.dlplssbz.hllChl
				// 增碳剂理论加入量
				this.ztjjrl = ((bzchl-xythl)/this.dlplssbz.cYxcfhl/this.dlplssbz.cXsl*100).toFixed(2)
				// 标准硅含量
				let bzsihl = formData.plzz*this.dlplssbz.siBz;
				// 现有硅含量
				let xysihl = formData.fgzz*this.dlplssbz.fgSihl+formData.stzz*this.dlplssbz.stSihl+(formData.plzz-formData.fgzz-formData.stzz)*this.dlplssbz.hllSihl
				// 硅铁粒理论加入量
				this.gtljrl = ((bzsihl-xysihl)/this.dlplssbz.siYxcfhl/this.dlplssbz.siXsl*100).toFixed(2)
				this.textColor = '#3E60D2';		
						
			}
		}
	}
</script>

<style>
@import "@/common/susuanht.css";

</style>
